﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ExtendedReportViewer
{
    class ReportPropertyDescriptor : PropertyDescriptor
    {
        private string displayName;
        private PropertyDescriptor innerPropDescr;

        public ReportPropertyDescriptor(PropertyDescriptor prop, string displayName): base(prop.Name, null)
        {
            this.innerPropDescr = prop;
            this.displayName = string.IsNullOrEmpty(displayName) ? prop.Name : displayName;
        }

        public override bool CanResetValue(object component)
        {
            return this.innerPropDescr.CanResetValue(component);
        }

        public override bool Equals(object other)
        {
            return this.innerPropDescr.Equals(other);
        }

        public override int GetHashCode()
        {
            return this.innerPropDescr.GetHashCode();
        }

        public override object GetValue(object component)
        {
            return this.innerPropDescr.GetValue(component);
        }

        public override void ResetValue(object component)
        {
            this.innerPropDescr.ResetValue(component);
        }

        public override void SetValue(object component, object value)
        {
            this.innerPropDescr.SetValue(component, value);
        }

        public override bool ShouldSerializeValue(object component)
        {
            return this.innerPropDescr.ShouldSerializeValue(component);
        }

        public override AttributeCollection Attributes
        {
            get
            {
                return this.innerPropDescr.Attributes;
            }
        }

        public override Type ComponentType
        {
            get
            {
                return this.innerPropDescr.ComponentType;
            }
        }

        public override string DisplayName
        {
            get
            {
                return this.displayName;
            }
        }

        public override bool IsBrowsable
        {
            get
            {
                return this.innerPropDescr.IsBrowsable;
            }
        }

        public override bool IsReadOnly
        {
            get
            {
                return this.innerPropDescr.IsReadOnly;
            }
        }

        public override Type PropertyType
        {
            get
            {
                return this.innerPropDescr.PropertyType;
            }
        }
    }
}
